package com.zs4sdk.entity;

import com.common.library.entity.JSONResultEntity;
import com.common.library.util.Helper;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 个人信息实体
 * Created by cxb on 2015/4/10.
 */
public class PersonInfoEntity extends JSONResultEntity {

    /**经验值**/
    private String vipgrade;
    /**经验值比率**/
    private String exp_rate;
    private int sex;
    private String persionsign;
    private String email;
    private String nickname;
    private int checknickname;
    private String profileimageurl;
    private String mobile;
    private String nnb;

    // 字段 名
    public static final String COLUMN_VIPGRADE = "vipgrade";
    public static final String COLUMN_EXP_RATE = "exp_rate";
    public static final String COLUMN_SEX = "sex";
    public static final String COLUMN_PERSIONSIGN = "persionsign";
    public static final String COLUMN_EMAIL = "email";
    public static final String COLUMN_NICKNAME = "login_name";  //原来为nickname  后来修改为login_name
    public static final String COLUMN_CHECKNAME = "checknickname";
    public static final String COLUMN_PROFILEIMAGEURL = "profileimageurl";
    public static final String COLUMN_MOBILE = "mobile";
    public static final String COLUMN_NNB = "nnb";

    /**
     * 构造方法
     */
    public PersonInfoEntity(){

    }
    /**
     * 构造方法
     * @param json
     */
    public PersonInfoEntity(JSONObject json){
        this.fromJSON(json);
    }

    /**
     * 构造方法
     * @param jsonStr
     */
    public PersonInfoEntity(String jsonStr){
        try{
            this.fromJSON(new JSONObject(jsonStr));
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void fromJSON(JSONObject json) {
        super.fromJSON(json);

        if(Helper.isNotEmpty(json)) {
            this.vipgrade = json.optString(COLUMN_VIPGRADE);
            this.exp_rate = json.optString(COLUMN_EXP_RATE);
            this.sex = json.optInt(COLUMN_SEX);
            this.persionsign = json.optString(COLUMN_PERSIONSIGN);
            this.email = json.optString(COLUMN_EMAIL);
            this.nickname = json.optString(COLUMN_NICKNAME);
            this.checknickname = json.optInt(COLUMN_CHECKNAME);
            this.profileimageurl = json.optString(COLUMN_PROFILEIMAGEURL);
            this.mobile = json.optString(COLUMN_MOBILE);
            this.nnb = json.optString(COLUMN_NNB);
        }
    }

    @Override
    public JSONObject toJSON() {
        JSONObject result = super.toJSON();
        try {
            result.put(COLUMN_VIPGRADE, this.vipgrade);
            result.put(COLUMN_EXP_RATE, this.exp_rate);
            result.put(COLUMN_SEX, this.sex);
            result.put(COLUMN_PERSIONSIGN, this.persionsign);
            result.put(COLUMN_EMAIL, this.email);
            result.put(COLUMN_NICKNAME, this.nickname);
            result.put(COLUMN_CHECKNAME, this.checknickname);
            result.put(COLUMN_PROFILEIMAGEURL, this.profileimageurl);
            result.put(COLUMN_MOBILE, this.mobile);
            result.put(COLUMN_NNB, this.nnb);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return result;
    }

    public String getVipgrade() {
        return vipgrade;
    }

    public void setVipgrade(String vipgrade) {
        this.vipgrade = vipgrade;
    }

    public String getExp_rate() {
        return exp_rate;
    }

    public void setExp_rate(String exp_rate) {
        this.exp_rate = exp_rate;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getPersionsign() {
        return persionsign;
    }

    public void setPersionsign(String persionsign) {
        this.persionsign = persionsign;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public int getChecknickname() {
        return checknickname;
    }

    public void setChecknickname(int checknickname) {
        this.checknickname = checknickname;
    }

    public String getProfileimageurl() {
        return profileimageurl;
    }

    public void setProfileimageurl(String profileimageurl) {
        this.profileimageurl = profileimageurl;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getNnb() {
        return nnb;
    }

    public void setNnb(String nnb) {
        this.nnb = nnb;
    }
}
